package com.keyancompany.zhongbaopingtai.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.Html;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.keyancompany.zhongbaopingtai.R;
import com.keyancompany.zhongbaopingtai.listener.IClickCancleListener;
import com.keyancompany.zhongbaopingtai.model.ComplainingModel;
import com.keyancompany.zhongbaopingtai.model.FindModel;

/**
 * 申诉列表适配器
 * <p>
 * Created by firefox on 2016/6/14.
 */
public class ComplainingAdapter extends ListAdapter<ComplainingModel> {

    private IClickCancleListener listener;


    public ComplainingAdapter(Context ctx, IClickCancleListener listener) {
        super(ctx);
        this.listener = listener;
    }

    @Override
    public int getContentViewId() {
        return R.layout.item_find;
    }

    @Override
    public HolderView getHoldView(int position, View contentView, ViewGroup parent) {
        FindHolder hold = new FindHolder();
        hold.collectionIcon = (ImageView) contentView.findViewById(R.id.find_collection);
        hold.technology = (TextView) contentView.findViewById(R.id.jinengyaoqiu);
        hold.time = (TextView) contentView.findViewById(R.id.find_time);
        hold.author = (TextView) contentView.findViewById(R.id.find_author);
        hold.content = (TextView) contentView.findViewById(R.id.find_content);
        hold.title = (TextView) contentView.findViewById(R.id.find_title);
        hold.yusuan = (TextView) contentView.findViewById(R.id.find_yusuan);
        hold.zhouqi = (TextView) contentView.findViewById(R.id.find_zhouqi);
        hold.bottomLinear = (LinearLayout) contentView.findViewById(R.id.bottom_parent);
        hold.bottomLinear.setVisibility(View.GONE);
        hold.collectionIcon.setVisibility(View.GONE);
        hold.technology.setTextColor(Color.RED);
        return hold;
    }

    @Override
    public void setItemView(final int position, HolderView contentView, ComplainingModel item) {
        FindHolder hold = (FindHolder) contentView;

//        hold.collectionIcon.setVisibility(item.getIsMe() == 1 ? View.GONE : View.VISIBLE);
        hold.title.setText(item.getProjectName());
        hold.content.setText("理由："+item.getReason());
        hold.time.setText(item.getCreateTime());
        hold.author.setText("");
        hold.technology.setText(item.getProgress());

//        hold.yusuan.setText(ctx.getString(R.string.yusuan_text, "" + item.getBudget()));
//        hold.zhouqi.setText(ctx.getString(R.string.zhouqi_text, item.getEndTime()));

    }


    class FindHolder extends HolderView {

        ImageView collectionIcon;

        TextView title;

        TextView content;

        TextView time;

        TextView author;

        TextView technology;

        TextView yusuan;

        TextView zhouqi;

        LinearLayout bottomLinear;
    }
}
